<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 0;
            /* 打字机效果，需要把文字的size和动画的长度对应起来 */
            font-size: 20px;
            overflow: hidden;
            height: 30px;
            background-color: pink;
            /* 文字强行一行内显示 */
            white-space: nowrap;
            /* animation: name duration timing-function delay iteration-count direction fill-mode; */
            /* 用steps就不能写linear了 */
            animation: w 4s steps(10) forwards;

        }
        @keyframes w {
            0% {
                width: 0;
            }
            100% {
                width: 200px;
            }
        }
    </style>
</head>
<body>
    <div>但将行好事切莫问前程</div>
</body>
</html>